package top.lyunz.fangkeji.tools;

/*
 * 图片上传工具类
 * 
 */
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import org.springframework.web.multipart.MultipartFile;

import top.lyunz.fangkeji.controller.web.web;

public class img {
	public boolean uploadingImg(MultipartFile file, String name) {
		if (!file.isEmpty()) {
			try {
				BufferedOutputStream out = new BufferedOutputStream(
						new FileOutputStream(new File(web.imgurlpath + name)));// 保存图片到目录下
				out.write(file.getBytes());
				out.flush();
				out.close();

			} catch (FileNotFoundException e) {
				e.printStackTrace();
				return false;
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return true;

	}
}
